<template>
  <a-modal
    :visible="visible"
    title="学生列表"
    :width="1000"
    okText="导出"
    cancelText="关闭"
    @cancel="() => { $emit('cancel') }"
    @ok="exportExcel"
  >
    <s-table
      ref="table"
      size="default"
      rowKey="key"
      :columns="columns"
      :data="loadData"
      :alert="{ show: false }"
      :scroll="{x: 1000}"
      >
      <span slot="serial" slot-scope="text, record, index">
        {{ index + 1 + (parameter.pageNo - 1) * parameter.pageSize }}
      </span>
    </s-table>
  </a-modal>
</template>

<script>
import { STable } from '~'

export default {
  props: ['visible'],
  components: { STable },
  data () {
    return {
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '学号',
          dataIndex: 'xh'
        },
        {
          title: '姓名',
          dataIndex: 'xm'
        },
        {
          title: '性别',
          dataIndex: 'xb'
        },
        {
          title: '年级',
          dataIndex: 'sznj'
        },
        {
          title: '院系',
          dataIndex: 'ssyxmc'
        },
        {
          title: '专业',
          dataIndex: 'sszymc'
        },
        {
          title: '学生类别',
          dataIndex: 'pyccmc'
        },
        {
          title: '导师',
          dataIndex: 'dsxm'
        },
      ],
      params: {},
      parameter: {
        pageNo: 1,
        pageSize: 10
      },
      loadData: parameter => {
        if (!Object.keys(this.params).length) {
          return
        }
        this.parameter = parameter
        parameter.pageNum = parameter.pageNo
        let params = Object.assign(this.params, parameter)
        return this.$api.cultivate.enrollmentStuList(params).then(res => {
          this.params.sznj = res.data.rows[0].sznj
          return {
            data: res.data.rows,
            pageNo: parameter.pageNo,
            pageSize: parameter.pageSize,
            totalPage: Math.ceil(res.data.total / parameter.pageSize),
            totalCount: res.data.total,
            
          }
        })
      }
    }
  },
  methods: {
    exportExcel () {
      // let exportApi
      // if (this.params.bdztm) {
      //   if (this.params.bdztm == '02') {
      //     exportApi = '/schoolRoll/bdzcxx/ybdrsExp'
      //   } else if (this.params.bdztm == '01') {
      //     exportApi = '/schoolRoll/bdzcxx/wbdrsExp'
      //   }
      // } else if (this.params.zcztm) {
      //   if (this.params.zcztm == '02') {
      //     exportApi = '/schoolRoll/bdzcxx/yzcrsExp'
      //   } else if (this.params.zcztm == '01') {
      //     exportApi = '/schoolRoll/bdzcxx/wzcrsExp'
      //   }
      // } else {
      //   exportApi = '/schoolRoll/bdzcxx/zrsExp'
      // }
      let params = {...this.params}
      delete params.pageNum
      
      this.$export('/foster/pyjh/xkrsExp', params)
    }
  }
}
</script>

<style>

</style>
